#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    vector<int>v(n+1);
    bool f=0;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
        if(i>2)
        {
            v[1]*=gcd(v[2],v[i]);
            v[2]/=gcd(v[2],v[i]);
        }
    }
    if(v[1]%v[2]==0)f=1;
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}